package org.acme.spring.web.common;

import java.io.Serializable;

public class R implements Serializable {
	public R(int code, String message, Object data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	private int code;
	private String message;
	private Object data;

	public static R wrapResult(String msg) {
		return new R(200, msg, null);
	}

	public static R wrapResult(String msg, Object data) {
		return new R(200, msg, data);
	}

	public static R wrapResult(int code, String msg) {
		return new R(code, msg, null);
	}

	public static R wrapResult(int code, String msg, Object data) {
		return new R(code, msg, data);
	}

	public static R wrapEffectResult(int effect) {
		return new R(200, effect > 0 ? "操作成功" : "操作失败", null);
	}

	public static R wrapEffectResult(boolean flag) {
		return new R(200, flag ? "操作成功" : "操作失败", null);
	}
}
